package com.johnzer.frame.utils.rxjava;


import com.johnzer.frame.network.interfaces.IHttpResult;

import org.reactivestreams.Subscription;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;

/**
 * Author   : johnzer
 * Data     : 2016-09-18  16:57
 * Describe : BaseSubscriber
 */

public abstract class BaseSubscriber<T>{

    private Consumer<? super T> next;
    private Consumer<? super Throwable> error;
    private Action onComplete;
    private Consumer<? super Subscription> onSubscribe;

    public BaseSubscriber(){
        next = this:: onNext;// 下一步的方法
        error = this::onError;// 错误的方法
        onComplete = this :: onComplete;// 完成的方法
        onSubscribe = this :: onSubscribe;// Subscription的方法
    }

    public abstract void onSubscribe(Subscription subscription);

    public abstract void onComplete();

    public abstract void onError(Throwable throwable);

    public abstract void onNext(T tiHttpResult);

    public Consumer<? super T> getNext() {
        return next;
    }
    public Consumer<? super Throwable> getError() {
        return error;
    }
    public Action getOnComplete() {
        return onComplete;
    }
    public Consumer<? super Subscription> getOnSubscribe() {
        return onSubscribe;
    }

}
